<?php

namespace App\Custom\Message;

use Siam\Sms\AliSms;
use Siam\Sms\TencentSms;


trait Main
{

    private $cloud;

    public function sendAliMessage()
    {

    }

    /**
     * 发数腾讯消息
     * @param $data
     * @return array
     */
    public function sendTencetMessage($data)
    {
        $config = get_setting('message');
        $key = $config['access_key'];
        $secret = $config['access_secret'];
        // 腾讯云短信发送短信需要指定应用id
        $appid =  $config['app_id'];
        $sign = $config['sign_name'];
        $template = $config['template_code'];
        // 创建
        $sms = new TencentSms($key, $secret);
        // 需要注意，设置配置不分先后顺序，send后也不会清空配置
        $result = $sms->setAppid($appid)
            ->setMobile($data['mobile'])
            ->setTemplate($template)
            ->setSign($sign)
            ->setParams(['code' => $data['code']])
            ->send();
        /**
         * 返回值为bool，你可获得腾讯云响应做出你业务内的处理
         *
         * status bool 此变量是此包用来判断是否发送成功
         * code string 腾讯云短信响应代码
         * message string 腾讯云短信响应信息
         */
        return $sms->getResponse();
    }
}
